﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NExplorer
{
	public struct LowerCaseString
	{
		public static readonly LowerCaseString Empty = new LowerCaseString("");

		private readonly string _value;

		public LowerCaseString(string value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}

			_value = value.ToLower();
		}

		public string Value
		{
			get { return _value; }
		}

		public override string ToString()
		{
			return _value;
		}

		public override int GetHashCode()
		{
			return _value.GetHashCode();
		}

		public override bool Equals(object obj)
		{
			if (obj is LowerCaseString)
			{
				return ((LowerCaseString)obj) == this;
			}
			else
			{
				return false;
			}
		}

		public static bool operator ==(LowerCaseString a, LowerCaseString b)
		{
			return string.CompareOrdinal(a.Value, b.Value) == 0;
		}

		public static bool operator !=(LowerCaseString a, LowerCaseString b)
		{
			return !(a == b);
		}
	}
}
